<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我的自定义邮件管理</title>
<link href="$!{__beat.server.contextPath}/css/css.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" href="$!{__beat.server.contextPath}/css/theme/font-awesome.min.css" type="text/css" />		
<link rel="stylesheet" href="$!{__beat.server.contextPath}/css/theme/bootstrap.min.css" type="text/css" />	
<link rel="stylesheet" href="$!{__beat.server.contextPath}/javascript/theme/libs/css/ui-lightness/jquery-ui-1.9.2.custom.css" type="text/css" />		
<link rel="stylesheet" href="$!{__beat.server.contextPath}/css/theme/App.css" type="text/css" />
<link rel="stylesheet" href="$!{__beat.server.contextPath}/css/theme/custom.css" type="text/css" />
<script src="$!{__beat.server.contextPath}/javascript/theme/libs/jquery-1.9.1.min.js"></script>
<script src="$!{__beat.server.contextPath}/javascript/theme/libs/jquery-ui-1.9.2.custom.min.js"></script>
<script src="$!{__beat.server.contextPath}/javascript/theme/libs/bootstrap.min.js"></script>
<script src="$!{__beat.server.contextPath}/javascript/theme/App.js"></script>

<script >
			$(function(){$("#clear").click(function(){ 
					$("#emailName").val("");
					$("#emailCate").val("");
                })
             });
			 
			 
			 function updateState(id,upstate){
				 var serchDate='';
				 if(upstate == '2'){
				 	serchDate=prompt("请输入测试日期:",'yyyy-MM-dd');
				 	var reg=/^(\d{4})-(\d{2})-(\d{2})$/;
				 	if(!reg.test(serchDate)){
				 		alert("日期格式不正确!");
				 		return false;
				 	}
				 }
				 	
			 	jQuery.ajax({
        			url:"$!{__beat.server.contextPath}/intemail/manager/changestate",
            		type:"post",
            		async:true,
            		data:{"upstate":upstate,"id":id,"serchDate":serchDate},
            		success:function(data){
                		if(data == "error"){
							alert("操作失败！");
						}else if(data == "success"){
							alert("操作成功！");
							window.location.href="$!{__beat.server.contextPath}/intemail/manager/show?pageindex=" + $('#curPage').val()
							+"&emailName="+$('#emailName').val()+"&emailCate="+$('#emailCate').val();
						}else{
							alert(date);
						}
            		}
            	});
            	if(upstate == '2')
			 		alert('正在执行，请耐心等待，并注意查收邮件!');
			 	
            	return false;
			 }
			 
			$(function(){$("#addnewemail").click(function(){ 
			 	window.location.href="$!{__beat.server.contextPath}/intemail/manager/toaddnewemail";
			 });
			});

			$(function(){$("#srcSearch").click(function(){ 
			 	window.location.href="$!{__beat.server.contextPath}/intemail/manager/iesrc/show";
			 });
			});

			 
		 
</script>

</head>
<body>
<div id="content" style="OVERFLOW-X:yes;OVERFLOW-Y:auto">		
			
	<div id="content-container">
		<form id="searchUser" name="searchUser" action="$!{__beat.server.contextPath}/intemail/manager/show" method="post">
    	<div class="portlet">
				<div class="portlet-header">
					<h3>
						<i class="fa fa-tasks"></i>
						我的自定义邮件
					</h3>
			
				</div> <!-- /.portlet-header -->
			
    				<div class="portlet-content">
						
    						<div class="form-group">
								<label class="col-md-2">邮件名：</label>
    							<div class="col-md-2">
    							  <input type="text" id="emailName" name="emailName" value="$!{emailName}"class="form-control"/>
    							</div>
    							<label class="col-md-2">所属类别：</label>
    							<div class="col-md-2">
    							  <input type="text" id="emailCate" name="emailCate" value="$!{emailCate}" class="form-control"/>
    							</div>
								&nbsp;&nbsp;&nbsp;&nbsp;
								<button type="submit" id="searchemail" name ="searchemail" class="btn btn-primary btn-xs">查询</button>
								&nbsp;&nbsp;&nbsp;&nbsp;
								<button type="button" id="srcSearch" name ="srcSearch" class="btn btn-primary btn-xs">数据源查询</button>
								&nbsp;&nbsp;&nbsp;&nbsp;
								<button type="button" id="addnewemail" name ="addnewemail" class="btn btn-primary btn-xs">定制新邮件</button>
    						</div>
    
    						
    			
    				</div> <!-- /.portlet-content -->
			
		</div> <!-- /.portlet -->	
        </form>
		
		
			<div class="portlet">
    
    					
							<div class="portlet-header">
    
    							<h3>
    								<i class="fa fa-hand-o-up"></i>
    								查询结果
    							</h3>
    							<input type='hidden' id='curPage' #if($pageIndex) value="$pageIndex" #else value="0" #end/>
    						</div> <!-- /.portlet-header -->
    
							
							
    						<div class="portlet-content">						
    							<div class="table-responsive">
    
									<!--table begin -->
        							<table 
        								class="table table-striped table-bordered table-hover" 
        								data-provide="datatable" 
        								data-display-rows="20"
        							>
        									<thead>
        										<tr>
													<th>邮件名称 </th>
													<th>所属类别 </th>
													<th>创建者</th>
													<th>修改时间</th>	
													<th>发送频率</th>
													<th>最近更新时间</th>
													<th>状态</th>
													<th>操作</th>
        										</tr>
        									</thead>
        									<tbody>
												 #foreach($rs in $rsList)
												 #set($send = $sendMap.get($rs.id))
                                            		<tr>
                                            		   <td>$rs.emailName</td>
                                                       <td>$rs.emailCate</td>
                                                	   <td>$rs.creater</td>
                                               		   <td>$rs.creatTime</td>
                                               		   <td>$!send.sendFre/$!send.sendTime</td>
                                               		   <td>$!send.updateTime</td>
                                               		   <td>$!send.warnTel</td>
                                                       <td id="reportstate" name="reportstate" >
                                        				<a style="color:green" href="$!{__beat.server.contextPath}/intemail/manager/toeditemail?id=$!{rs.id}">修&nbsp;&nbsp;改</a> &nbsp;
                                        				#if($rs.state == 1)
                                        					<a style="color:red" href="javascript:void(0)" onclick="updateState('$rs.id','0')">失&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;效</a>&nbsp; 
                                        				#elseif($rs.state == 0)
                                        					<a style="color:blue" href="javascript:void(0)" onclick="updateState('$rs.id','1')">加入调度</a>&nbsp;
                                        				#end
                                        				<a style="color:green" href="$!{__beat.server.contextPath}/intemail/manager/iesrcshow?id=$!{rs.id}&emailName=$rs.emailName&emailCate=$rs.emailCate">数据源</a> &nbsp; 
                                        				<a style="color:blue" href="$!{__beat.server.contextPath}/intemail/manager/toexecute?id=$!{rs.id}">执&nbsp;&nbsp;行</a>
                                        			   </td>
                                                    </tr>	
                                        		#end
												
        									</tbody>
        								
        							</table>
        							<!--table end -->
										
    								<!--paginate begin -->
    								<div class="row dt-rb">
    									#parse("/views/default/newpage.vm")
										#pagenew($pList "$!{__beat.server.contextPath}/intemail/manager/show?#page#&$paramurl")
                                    </div>
    								<!--paginate end -->
    								
									
                                </div>
							</div> <!-- /#portlet-content -->
								
							 
								
    						</div> 
		
		
	</div> <!-- /#content-container -->
	
</div> <!-- #content -->
	

</body>
</html>